<?php
/**
 * 权限与路由关联
 */
namespace App\Models\MainDB\Access;

use Illuminate\Database\Eloquent\Model;

class AccessRouteJoin extends Model
{
    protected $table = 'ln_access_route_join';

    protected $primaryKey = 'id';

    protected $fillable = [
        'id', //主键
        'access_id', //权限id
        'route_id', //路由id
    ];

    public $timestamps = false;

    //查询已绑定权限的路由id
    public function getAllRouteIds()
    {
        return app('model_access_route_join')
            ->select('route_id')
            ->groupBy('route_id')
            ->pluck('route_id')->toArray();
    }

    public function add($data)
    {
        return $this->insert($data);
    }
}